package com.example.capsule_chat0322.adapter;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

/**
 * @Author zhuzhiming
 * @Date 2022/5/1 14:14
 */
public class NavigateAdapter extends FragmentPagerAdapter {


    private List<Fragment> mFragments;
    private List<String> mtitle;

    public NavigateAdapter(@NonNull FragmentManager fm, List<Fragment> mFragments, List<String> mtitle) {
        super(fm);
        this.mFragments=mFragments;
        this.mtitle=mtitle;
    }

    @NonNull
    @Override  //返回指定fragment
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override  //返回fragment数量
    public int getCount() {
        return mFragments.size();
    }

    @Nullable
    @Override  //获取分页标题
    public CharSequence getPageTitle(int position) {
        return mtitle.get(position);
    }


}
